home *** CD-ROM | disk | FTP | other *** search
/ Scene 96 / Scene 96 International Edition (Zyklop Software) (Disc 2) (1997).iso / misc / coding / e_os208 / example3 / example3.asm next >
Assembly Source File  |  1996-06-09  |  4KB  |  120 lines

  1. ;╔══════════════════════════════════════════════════════════════════════════╗
  2. ;║                                                                          ║
  3. ;║ This example show how to use EOSLITE, the memory and the selectors       ║
  4. ;║                                                                          ║
  5. ;║ Tabs : 13 21 29 37                                                       ║
  6. ;║                                                                          ║
  7. ;╚══════════════════════════════════════════════════════════════════════════╝
  8.  
  9. Locals
  10. .386
  11. CODE32 SEGMENT PUBLIC PARA 'CODE' USE32
  12. ASSUME  CS:CODE32,DS:CODE32,ES:CODE32
  13.  
  14. INCLUDE ..\RESOURCE\EOS.INC
  15.  
  16. Msg_Ok       db '    ■ Allocate 1024 Mbytes ',13,10,36
  17.  
  18. Msg_Memory   db '    ■ Not Enough Memory ...',13,10,36
  19.  
  20. Msg_Selector db '    ■ No Free Selector ...',13,10,36
  21.  
  22. Msg_Filling1 db '    ■ Filling With Logical Address',13,10,36
  23.  
  24. Msg_Filling2 db '    ■ Filling With Selector Buffer',13,10,36
  25.  
  26.  
  27. Logical_Address dd 0
  28. Selector_Buffer dw 0
  29.  
  30.  
  31. Start32:
  32.             mov ah,Use_Int_09       ; Use Int 09 From EOS Easy to use !!
  33.             mov bx,On
  34.             Int_EOS
  35.  
  36.             mov ah,Use_Int_08       ; Use Int 08 to wait a stable Frame
  37.             mov bx,On
  38.             Int_EOS
  39.  
  40.             mov ah,9
  41.             mov edx,O Msg_Ok
  42.             int 21h
  43.  
  44.             mov ah,Allocate_Memory
  45.             mov edx,1048576         ; Allocate 1024Mb
  46.             Int_EOS
  47.             jnc Allocate_Ok
  48.  
  49.             mov ah,Exit_Error
  50.             mov edx,O Msg_Memory
  51.             Int_EOS
  52.  
  53. Allocate_Ok:
  54.             mov [Logical_Address],edx ; Save the Address of the buffer
  55.             mov esi,eax
  56.             mov ah,Allocate_Selector  ; Allocate a selector with
  57.             mov edi,-1                ; start address from the buffer
  58.             Int_EOS
  59.             jnc Selector_Ok
  60.  
  61.             mov ah,Exit_Error         ; very very rare error
  62.             mov edx,O Msg_Selector    ; you have 16 Selector Free Min
  63.             Int_EOS
  64.  
  65. Selector_Ok:
  66.             mov [Selector_Buffer],bx
  67.  
  68.             mov ah,9                  ; Display first message
  69.             mov edx,O Msg_Filling1
  70.             int 21h
  71.  
  72. Loop_1:
  73.             xor eax,eax               ; Fill the buffer with the logical
  74.             mov edi,[Logical_Address] ; address  ES=DS=[Data32_Sel]
  75.             mov ecx,262144
  76.             rep stosd
  77.  
  78.             mov ah,Wait_Vbl
  79.             Int_EOS
  80.  
  81.             cmp [Key_Map+All],Off     ; Wait a key
  82.             je Loop_1
  83.  
  84.             mov [Key_Map+All],Off     ; Clear keyboard buffer
  85.  
  86.             mov ah,9                  ; Display second message
  87.             mov edx,O Msg_Filling2
  88.             int 21h
  89.  
  90. Loop_2:
  91.             xor eax,eax               ; Fill the buffer with a selector
  92.             xor edi,edi               ; EDI = 0 begin of selector
  93.             mov es,cs:[Selector_Buffer] ; ES = [Selector_Buffer]
  94.             mov ecx,262144
  95.             rep stosd
  96.  
  97.             mov ah,Wait_Vbl
  98.             Int_EOS
  99.  
  100.             cmp [Key_Map+All],Off     ; Wait a key
  101.             je Loop_2
  102.  
  103.             mov es,cs:[Data32_Sel]  ; Must have NO selector register use
  104.                                     ; the Selector_Buffer before Calling
  105.                                     ; DeAllocate_Selector
  106.  
  107.             mov ah,DeAllocate_Selector
  108.             mov bx,[Selector_Buffer]
  109.             Int_EOS
  110.  
  111.             mov ah,Deallocate_Memory
  112.             Int_EOS
  113.  
  114.             mov ax,4c00h
  115.             int 21h                 ; Exit with Error Code 0
  116.  
  117.  
  118.             CODE32 ENDS
  119.  
  120.             END